import apiRequest from '@/plugins/apiRequest.js';
// magic接口的基础路径
const magicApiContextPath = "/iszsq";

/**
 * 接口模块
 */
// app应用端接口
import App from './modules/app.js';


/**
 * 接口请求管理
 */
const api = {
	app: App,
	file: {
		/**
		 * 上传文件
		 * @param {Object} file 文件对象
		 */
		upload(file){
			let fileName = file.name;
			
			return apiRequest.upload(
				'/file/upload', 
				{
					// #ifdef MP-ALIPAY
					fileType: 'image/video/audio', // 仅支付宝小程序，且必填。
					// #endif
					filePath: file.url, // 要上传文件资源的路径。
					name: 'file',
					// 额外的表单数据
					formData: {
						
					},
				}
			);
		},
	},
	/**
	 * 用户鉴权相关 模块
	 */
	user: {
		/**
		 * 登录
		 * @param data { username: '', password: '', }
		 */
		login(data){
			// 返回一个promise对象
			let res = apiRequest.post(
				magicApiContextPath+'/userAuth/login', 
				data,
			);
			return res;
		},
	},
	// 店铺
	shop: {
		get(data){
			let res = apiRequest.post(
				magicApiContextPath+'/shop/get', 
				data,
			);
			return res;
		},
		save(data){
			let res = apiRequest.post(
				magicApiContextPath+'/shop/save', 
				data,
			);
			return res;
		},
		myShopList(data){
			let res = apiRequest.post(
				magicApiContextPath+'/shop/myShopList', 
				data,
			);
			return res;
		},
	},
	// 发型案例
	hairdoExample: {
		query(data){
			let res = apiRequest.post(
				magicApiContextPath+'/hairdoExample/query', 
				data,
			);
			return res;
		},
		get(data){
			let res = apiRequest.post(
				magicApiContextPath+'/hairdoExample/get', 
				data,
			);
			return res;
		},
		save(data){
			let res = apiRequest.post(
				magicApiContextPath+'/hairdoExample/save', 
				data,
			);
			return res;
		},
		del(data){
			let res = apiRequest.post(
				magicApiContextPath+'/hairdoExample/del', 
				data,
			);
			return res;
		},
	},
	// 广告轮播、公告
	banner: {
		query(data){
			let res = apiRequest.post(
				magicApiContextPath+'/banner/query', 
				data,
			);
			return res;
		},
		get(data){
			let res = apiRequest.post(
				magicApiContextPath+'/banner/get', 
				data,
			);
			return res;
		},
		save(data){
			let res = apiRequest.post(
				magicApiContextPath+'/banner/save', 
				data,
			);
			return res;
		},
		del(data){
			let res = apiRequest.post(
				magicApiContextPath+'/banner/del', 
				data,
			);
			return res;
		},
	},
	// 门票管理
	goods: {
		query(data){
			let res = apiRequest.post(
				magicApiContextPath+'/goods/query', 
				data,
			);
			return res;
		},
		get(data){
			let res = apiRequest.post(
				magicApiContextPath+'/goods/get', 
				data,
			);
			return res;
		},
		save(data){
			let res = apiRequest.post(
				magicApiContextPath+'/goods/save', 
				data,
			);
			return res;
		},
		del(data){
			let res = apiRequest.post(
				magicApiContextPath+'/goods/del', 
				data,
			);
			return res;
		},
	},
	// 地区，城市投票
	sysArea: {
		// 城市列表
		cityList(){
			let res = apiRequest.get(
				magicApiContextPath+'/sysArea/cityList', 
			);
			return res;
		},
		// 给城市投票
		cityVoting(data){
			let res = apiRequest.get(
				magicApiContextPath+'/sysArea/cityVoting',
				 {
					 params: data
				 }
			);
			return res;
		},
	},
};

export default api;